<template>
  <div>
    <input v-focus type="text">
    <p v-color ="'red'">你好</p>
    <p v-color="isCon">你是谁</p>
    <button @click="isCon ='green'">点我呀</button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isCon:'blue'
    }
  },
 directives:{
   focus:{
     inserted(el){
       el.focus()
     },
   },
   color:{
       inserted(el){
         el.style.color='red'
       },
       update(el,binding){
         el.style.color=binding.value
       }
     }
 }
}
</script>